package com.spirng.leetcode.day05;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;

public class MyStack {


    Deque<Integer> queue1;
    public MyStack() {
        queue1=new LinkedList<>();
    }

    public void push(int x) {
        queue1.offer(x);
    }

    public int pop() {

        for (int i = 0; i < queue1.size()-1; i++) {
            queue1.add(queue1.poll());
        }
        int result=queue1.poll();
        return result;
    }

    public int top() {
       return queue1.peekLast();
    }

    public boolean empty() {
        return queue1.isEmpty();
    }
}
